(function () {

    var app = {
        GloabalFooter: function () {
            var handler = $('#bottomNavHanddler');
            var target = $('#gloabalFooter');
            var main = $('#mainContent');

            handler.on('click', function (event) {
                event.preventDefault();
                target.toggleClass("open");

                if (target.hasClass("open")) {
                    target.animate({
                        height: '50px'
                    }, 300);
                    handler.animate({
                        bottom: '60px'
                    }, 200);
                    main.css({
                        'padding-bottom': '51px'
                    });
                } else {
                    target.animate({
                        height: '0px'
                    }, 300);
                    handler.animate({
                        bottom: '10px'
                    }, 200);
                    main.css({
                        'padding-bottom': '0px'
                    });
                }
            })
        },

        showTexts: function () {
            $('.texts').fadeIn();
        },

        diyTool: function () {
            var tips = $('.sendTips');
            var box = $('.diyBox');
            var card = $('.cardBody');
            var to = $('.to').text();
            var greetings = $('.greetings').text();
            var from = $('.from').text();

            $('#sendIt').on('click', function () {
                tips.show();
                card.addClass('blurIt');
            });
            $('#diy').on('click', function () {
                $('input[name=to]').val(to);
                $('input[name=from]').val(from);
                $('textarea[name=greetings]').val(greetings);
                box.show();
                card.addClass('blurIt');
            });
            $('.btnCancel').on('click', function () {
                box.fadeOut();
                card.removeClass('blurIt');
            });
            $('.sendTips').on('click', function () {
                $(this).fadeOut();
                card.removeClass('blurIt');
            });
        }
    };

    $(document).ready(function () {
        app.showTexts();
        app.diyTool();
    });

    $(window).load(function () {
        $('#joyRideTipContent').joyride({
            autoStart: true,
            postStepCallback: function (index, tip) {
                if (index == 2) {
                    $(this).joyride('set_li', false, 1);
                }
            },
            modal: true,
            expose: true
        });
    });

})();